<script type="text/javascript">
	$(function() {
		console.log($("#borrowTimeType").val()); 
	    $.fn.dataGridOptions.addBorrowFormSubFun("#form",'/modules/loan/borrow/updateBorrow.html');	
	    var $award = $("select[name='award']"), $part_account = $("#part_account");
	    //	首次进入修改页面，进行判断
	    if ($award.val() == 0) {
			$part_account.prop("disabled", true);
			$part_account.val('');
		} else {
			$part_account.prop("disabled", false);
			$part_account.attr("data-options","validType:'rewardRatio[0.1,6]',required: true");
			$.parser.parse($(".borrowForm")); 
		}
	    //	是否奖励
		$award.change(function() {
			if ($(this).val() == 0) {
				$part_account.prop("disabled", true);
				$part_account.val('');
				$part_account.attr("data-options","");
				$part_account.removeClass("validatebox-invalid");
				$.parser.parse($(".borrowForm")); 
			} else {
				$part_account.prop("disabled", false);
			    $part_account.attr("data-options","validType:'rewardRatio[0.1,6]',required: true");
				$.parser.parse($(".borrowForm")); 
			}
		});
		//	是否定向标
	    $("#isDXB").click(function(){
	    	if($('#isDXB').attr("checked"))
			{	
		        $('#pwd').attr("disabled",false);
		     	$('#pwd').attr("data-options","required: true");
		     	$.parser.parse($(".borrowForm"));
		    }else{
		        $('#pwd').attr("disabled",true);
		        $('#pwd').val("");
		        $('#pwd').attr("data-options","");
		        $('#pwd').removeClass("validatebox-invalid");	// 当输入框内填写非法时，取消定向密码，应删除提示非法的类名
		        $.parser.parse($(".borrowForm"));
		    }
	    });
		// 是否天标
	    $('#changetoDay').on('click',function(){
			if(!$('#borrow_day').is(":animated")){
				var dayManageFee = ${dayManageFee};
				var manageFee= ${manageFee};				
				var borrowTimeType=$('#borrowTimeType').val();
				if(borrowTimeType==0){
					$(this).addClass("dayhover")
					$('#borrowTimeType').val('1');
					$('#time_limit_day_box').html('<@linkage name="timeLimit" id="time_limit_day" class="select_low" default="${borrow.timeLimit!}" type="value" nid="borrow_time_limit_day"/>');
					$('#time_limit_day').addClass("J_input")
					$('#time_limit_box').html('')
					$('#style').html('<option value="2">一次性还款</option>');
			
				}else if($("#typeId").val()!=101){
					$(this).removeClass("dayhover")
					$('#borrowTimeType').val('0');
					$('#time_limit_day_box').html('')
					$('#time_limit_box').html('<@linkage name="timeLimit" id="time_limit" class="J_input select_low" default="${borrow.timeLimit!}" type="value" nid="borrow_time_limit"/>')
					$('#time_limit').addClass("J_input");
					$('#time_limit').show();
					$('#style').html('<option value="1">按月分期还款</option><option value="2">一次性还款</option><option value="3">每月还息到期还本</option>');
					
				}
				borrowTimeType=$('#borrowTimeType').val();
			}
	    });
	    $("#vouch").click(function(){
	    	$("#vouchFirms").toggle();
	    });
	    
	    <#if borrow.vouchFirm??>
	    	$("#vouch").click();
	    </#if>
	});
</script>
<form id="form" method="post" enctype="multipart/form-data">
<div class="borrowForm" style="border-top:none;">
<#if map??&&map.get("award")??>
	<#assign award=map.get("award")?eval />
</#if>
<#if map??&&map.get("partAccount")??>
	<#assign partAccount=map.get("partAccount") />
</#if>
<#if map??&&map.get("funds")??>
	<#assign funds=map.get("funds") />
</#if>
	<input type="hidden" id="dayManageFee" value="${dayManageFee!}"/>
	<input type="hidden" id="manageFee" value="${manageFee!}"/>
	<input type="hidden" name="dealNo" value="${borrow.uuid!}"/>
	<input type="hidden" name="bidNo" value="${borrow.uuid!}"/>
	<#if borrow.type!=101&&borrow.type!=103>
		<h1 class="borrowFormTitle">【标设置】</h1>
	    <div class="borrowSetting">
	    
	        <input type="radio" class="radio" id="specal1" name="category" value="1" <#if borrow.category==1>checked="checked"  </#if> >
	        <label for="specal1">普通标</label>
	        <input type="radio" id="specal2" name="category" value="0" <#if borrow.category==0>checked="checked"  </#if>>
	        <label for="specal2">新手专享</label>
	        <input type="radio" id="specal3" name="category" value="2" <#if borrow.category==2>checked="checked"  </#if>>
	        <label for="specal3">体验标</label>
	    </div>
	 <#else>
	    <input name="category" type="hidden" value="1"/>
	 </#if>
	<h1 class="borrowFormTitle">基本信息</h1>
	<ul>
		<li><span>标名称：</span><input type="text" name="name" maxlength="25" value="${borrow.name!}" autocomplete="off" class="borrowFormTxt easyui-validatebox" data-options="required: true,validType:'maxLength[25]'"></li>
		<li><span>借款人手机号：</span>${user.mobilePhone}</li>
		<#if borrow.type!=101>
		<li><span>开标时间</span><input type="text" value="<#if borrow.putStartTime??>${borrow.putStartTime?string('yyyy-MM-dd HH:mm:ss')} <#else></#if> " name="putStartTime" id="startTime" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',readOnly:true})" data-options="required: true" /></li>
        </#if>
		<li><span>借款总金额：</span><input type="text" maxlength="10" name="account" value="${borrow.account!}" autocomplete="off" onkeyup="value=value.replace(/[^0-9]/g,'')" size="15" class="borrowFormTxt1 easyui-validatebox" data-options="required: true,validType:'accout[500,5000000]'"><em>元</em></li>
		<li><span>借款年利率：</span><input type="text" name="apr" maxlength="5" onkeyup="value=value.replace(/[^0-9.]/g,'')" value="${borrow.apr!}" autocomplete="off" size="15" class="borrowFormTxt1 easyui-validatebox" data-options="required: true,validType:'apr[0,24]'"><em>%</em></li>
		
		<li><span>借款用途：</span><@linkage name="borrowUse" id="use" class="borrowFormTxt J_input" default="${borrow.borrowUse}" type="value" nid="borrow_use" /></li>
		<li>
			<span>是否天标：</span>
			<#if borrow.borrowTimeType==1><!-- 天标 -->
			<input type="checkbox" id="changetoDay" class="day_chose" checked="checked">
			<#else>
			<input type="checkbox" id="changetoDay" class="day_chose" >
			</#if>
		</li>
		<li id="borrow_day" style="display:none;">
			<span>是否天标：</span>
			<input type="hidden" name="borrowTimeType" id="borrowTimeType" value="${borrow.borrowTimeType}" />
			<input type="checkbox" checked="checked" disabled="disabled">
		</li>
		<li><span>借款期限：</span>
			<#if borrow.type==101>
	        	<input type="text"  class="borrowFormTxt J_input easyui-validatebox" value="满标即还" readonly="readonly" />
	        <#else>
	        	<#if borrow.borrowTimeType==0>
		        	<label id="time_limit_box"><@linkage name="timeLimit" id="time_limit" class="J_input select_low" default="${borrow.timeLimit!}" type="value" nid="borrow_time_limit"/></label>
	        	<#elseif borrow.borrowTimeType==1>
	        		<label id="time_limit_box"><@linkage name="timeLimit" id="time_limit" class="J_input select_low" default="${borrow.timeLimit!}" type="value" nid="borrow_time_limit_day"/></label>
	        	</#if>
	        	<label id="time_limit_day_box"></label>
	        </#if>
		</li>
		<li>
			<span>还款方式：</span>
			<#if borrow.type==101>
			<select name="style" disabled="disabled">
	        	<option value="2">
	        		一次性还款
	        	</option>
	        </select>
	        <input type="hidden" name="style" value="2">
	        <#elseif borrow.type!=101>
	        	<@linkage name="style" id="style" default="${borrow.style}" nid="borrow_style" type="value" class="J_input" />
	        <#else>
	        	<@linkage name="style" id="style" nid="borrow_style" type="value" class="J_input" />
	        </#if>
		</li>
		<li>
   			<span>奖励方式：</span>
   			<select name="award">
   				<option value="0" <#if borrow?exists&&borrow.award==0>selected=selected</#if>>没有奖励</option>
   				<option value="1" <#if borrow?exists&&borrow.award==1>selected=selected</#if>>比例奖励</option>
   			</select>
     	</li>
		<li><span>投标奖励比例：</span><input type="text" id="part_account" maxlength="5" onkeyup="value=value.replace(/[^0-9.]/g,'')" name="partAccount" <#if borrow.partAccount==0>value=""<#else>value="${borrow.partAccount!}"</#if> autocomplete="off" class="borrowFormTxt1 easyui-validatebox" size="15" ><em>%</em></li>
		<!-- <li><span>还款结束后奖励：</span><input type="hidden" name="lateAward" class="w300 easyui-validatebox" value="${borrow.lateAward!}" size="15"></li> -->
		<li><span>是否是定向标：</span><input id="isDXB" type="checkbox" name="isDXB" value="1" size="15" class="easyui-validatebox" <#if borrow.pwd?exists&&borrow.pwd!="">checked="true"</#if>> </li>
		<li><span>定向标密码：</span><input type="text" name="pwd" size="15"onkeyup="value=value.replace(/[^0-9]/g,'')"   class="borrowFormTxt easyui-validatebox" id="pwd" <#if borrow.pwd?exists&&borrow.pwd!="">value="${borrow.pwd}"   <#else>disabled="disabled"</#if>> </li>
		<#if borrow.type!=110&&borrow.type!=117>
		<li><span>最低投标金额：</span>
			<#if borrow?exists>
	        <@linkage name="lowestAccount" class="J_input" id="lowest_account" default="${borrow.lowestAccount}" nid="borrow_lowest_account"  type="value"/>
	        <#else>
	        <@linkage name="lowestAccount" class="J_input" id="lowest_account" nid="borrow_lowest_account" type="value" />
	        </#if>
        </li>
		<li><span>最高投标总额：</span>
			<#if borrow?exists>
	        <@linkage name="mostAccount" class="J_input" id="most_account" default="${borrow.mostAccount}" nid="borrow_most_account" type="value" />
	        <#else>
	        <@linkage name="mostAccount" class="J_input" id="most_account" nid="borrow_most_account" type="value" />
	        </#if>
	        <input type="hidden" id="typeStr" name="typeStr" value="${borrow.type}" />
		</li>
		</#if>
		<#if borrow.type==117>
			<li><span>最低投标金额：</span>
				<#if borrow?exists>
			    <li><span>借款总金额：</span><input type="text" maxlength="10" name="lowestAccount" value="${borrow.lowestAccount!}" autocomplete="off" onkeyup="value=value.replace(/[^0-9]/g,'')" size="15" class="borrowFormTxt1 easyui-validatebox" data-options="required: true,validType:'accout[0,10000]'"><em>元</em></li>
				</#if>
			</li>
			<li><span>最高投标总额：</span>
				<#if borrow?exists>
					<@linkage name="mostAccount" class="J_input" id="most_account" default="${borrow.mostAccount}" nid="borrow_most_account" type="value" />
					<#else>
						<@linkage name="mostAccount" class="J_input" id="most_account" nid="borrow_most_account" type="value" />
				</#if>
				<input type="hidden" id="typeStr" name="typeStr" value="${borrow.type}" />
			</li>
		</#if>
		<#if borrow.type==110>
		<li><span>每份投标金额：</span><input type="text" name="flowMoney" value="${borrow.flowMoney}" class="borrowFormTxt easyui-validatebox" size="15"><em>元</em></li>
		<li><span>单笔最低投标金额：</span><@linkage name="lowestSingleLimit" class="J_input" id="lowest_single_limit" default="${borrow.lowestSingleLimit}" nid="borrow_most_account"  type="value"/></li>
		<li><span>单笔最多投标总额：</span><@linkage name="mostSingleLimit" class="J_input" id="most_single_limit" default="${borrow.mostSingleLimit}" nid="borrow_most_account" type="value" /></li>
		</#if>
		<li><span>添加时间：</span>${borrow.addTime?string("yyyy-MM-dd HH:mm:ss")}</li>
		<li><span>IP：</span>${borrow.addIp}</li>
		<li><span>是否是推荐标：</span>
			<#if isRecommend==1><!-- 推荐 -->
				<input type="checkbox" id="isRecommend" name="isRecommend" checked="checked" value="1">
				<#else>
					<input type="checkbox" id="isRecommend" name="isRecommend" value="1">
			</#if></li>
		<input type="hidden" name="userId" value="${user.userId}">
		<input type="hidden" name="id" value="${borrow.id}">
		<input type="hidden" name="type" value="${borrow.type}">
		<input type="hidden" name="borrowManageRate" value="${borrow.borrowManageRate}">
	</ul>
	<div class="borrowFormMuti"><span>借款详情：</span>
	<#include "../../column/article/umeditor.htm">
	<@showUeditor width=650 heigth=400 id="articleEditor" name="content" content="${borrow.content!}"/>
	</div>
</div>
<!-- 图片列表 -->
<div class="borrowForm">
	<h1 class="borrowFormTitle">图片资料</h1>
	<div id="uploadGuaranteeBox" class="uploadWrap" data-arr="uploadFile">
        <ul id="borrowPagePic" class="photoUpload">
            <li class="addFileBtn">
              <input type="file" name="file" class="uploadFileInput" id="uploadFile" onchange="return ajaxFileUpload1('uploadFile','/imageUp.jsp?editorid=borrow','picPath');" title="点击上传图片" />
            </li>
            <#list picList as pic>
            <#if pic.type==4>
            <li data-mum="${pic.id}">
               <a href="${image_server_url}${pic.picPath}" class="fileshow" rel="guaranteePic"><img src="${image_server_url}${pic.picPath}"/></a>
               <a class="closePic" style="float:left;" href="javascript:;" title="删除图片">x</a>                     
           	</li>
           	</#if>
           	</#list>
        </ul>
   </div>	
</div>
<!-- 图片列表 -->
<div class="borrowForm">
	<h1 class="borrowFormTitle">缩略图</h1>
	<div class="uploadWrap" data-arr="uploadFile">
        <ul id="thumbnailPic" class="photoUpload">
            <li class="addFileBtn">
              <input type="file" name="thumbnailFile" class="uploadFileInput" id="uploadThumbnailFile" onchange="return ajaxFileUpload3('uploadThumbnailFile','/imageUp.jsp?editorid=borrow','thumbnailPath');" title="点击上传图片" />
            </li>
            <#list picList as pic>
            <#if pic.type==6>
            <li data-mum="${pic.id}">
               <a href="${image_server_url}${pic.picPath}" class="fileshow" rel="guaranteePic"><img src="${image_server_url}${pic.picPath}"/></a>
               <a class="closePic" style="float:left;" href="javascript:;" title="删除图片">x</a>                     
           	</li>
           	</#if>
           	</#list>
        </ul>
   </div>	
</div>
<input type="hidden" name="uuid" value="${borrow.uuid!}"/>
</form>
<script type="text/javascript">seajs.use("${theme_dir}/js/ajaxfileupload");seajs.use("${theme_dir}/js/upload");</script>
<!-- 图片预览-->
<script type="text/javascript">

	 $(function() {
	       if ( "${borrow.category}"==1){
	        $("specal1").attr("checked","checked");
	    }else{
	        $("specal2").attr("checked","checked");
	    }
	       
	 });
	$(".fileshow").fancybox();
	 $('.l-btn-text').click(function(){
		 if($("#borrowPagePic li").length<=1){
			 layer.alert('请上传图片资料', 8);
			 return false;
		 }

		 /*
		 if($("#thumbnailPic li").length<=1){
			 layer.alert('请上传缩略图', 8);
			 return false;
		 }
		 */
	 })

</script>


<script>
  most_account = $("#most_account");
  lowest_account = $("#lowest_account");
  
  most_account.change(function() {
	  most_account_val = parseInt(most_account.find("option:selected").html().replace("元",""));
	  lowest_account_val = parseInt(lowest_account.find("option:selected").html().replace("元",""));
  if(most_account_val<lowest_account_val)
  {
          //构造确认框DOM
          $.layer({
              type: 1,
              closeBtn: [0,true],
              title: "温馨提示",
              area: ['460px', '194px'],
              border: [1, 1, '#cecfd0'],
              page: {
                  html: '<div class="tipsWrap" style="padding-left:100px;padding-top:50px;">最高投标金额不能小于最低投标金额。</div>'
              },
            close:function(){
            	$("#most_account").addClass("validatebox-invalid");
            }
          }); 
  }
  else{
	  $("#most_account").removeClass("validatebox-invalid");
  }
  })
  
	lowest_account.change(function() {
	most_account_val = parseInt(most_account.find("option:selected").html().replace("元",""));
	lowest_account_val = parseInt(lowest_account.find("option:selected").html().replace("元",""));
	  if(most_account_val<lowest_account_val) {
          //构造确认框DOM
          $.layer({
              type: 1,
              closeBtn: [0,true],
              title: "温馨提示",
              area: ['460px', '194px'],
              border: [1, 1, '#cecfd0'],
              page: {
                  html: '<div class="tipsWrap" style="padding-left:100px;padding-top:50px;">最高投标金额不能小于最低投标金额。</div>'
              },
            close:function(){
            	$("#most_account").addClass("validatebox-invalid");
            }
          });
	} else{
		$("#most_account").removeClass("validatebox-invalid");
  	}
  })
</script>
